
package com.autumn.zero.workflow.entitys;

import java.util.Date;

import javax.persistence.Column;
import javax.validation.constraints.NotNull;

import org.apache.ibatis.type.JdbcType;
import org.hibernate.validator.constraints.Length;

import com.autumn.domain.entities.auditing.AbstractGmtCreateEntity;
import com.autumn.mybatis.mapper.annotation.ColumnOrder;
import com.autumn.mybatis.mapper.annotation.ColumnType;
import com.autumn.mybatis.mapper.annotation.Index;
import com.autumn.validation.annotation.NotNullOrBlank;

/**
 * 工作流进程
 * 
 * @author 杨昌国 2019-01-10 18:59:25
 */
public abstract class AbstractWorkflowProcess extends AbstractGmtCreateEntity<Long> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7446223607088917894L;

	/**
	 * 最大流程名称长度
	 */
	public static final int MAX_FLOW_NAME_LENGTH = 50;

	/**
	 * 最大标题长度
	 */
	public static final int MAX_FLOW_TITLE_LENGTH = 250;

	/**
	 * 最大 processInstanceId 长度
	 */
	public static final int MAX_PROCESS_INSTANCE_ID_LENGTH = 20;

	/**
	 * 最大 processDefinitionId 长度
	 */
	public static final int MAX_PROCESS_DEFINITION_ID_LENGTH = 255;

	/**
	 * 最大 processId 长度
	 */
	public static final int MAX_PROCESS_ID_LENGTH = 255;

	/**
	 * 最大 startUserId 长度
	 */
	public static final int MAX_START_USER_ID_LENGTH = 64;

	/**
	 * 最大 startUserName 长度
	 */
	public static final int MAX_START_USER_NAME_LENGTH = 100;

	/**
	 * 最大 statusMessage 长度
	 */
	public static final int MAX_STATUS_MESSAGE_LENGTH = 255;

	/**
	 * 最大 processDefinitionVersion 长度
	 */
	public static final int MAX_PROCESS_DEFINITION_VERSION_LENGTH = 20;

	/**
	 * 最大表单编号长度
	 */
	public static final int MAX_FORM_NO_LENGTH = 64;

	/**
	 * 字段 formType
	 */
	public static final String FILED_FORM_TYPE = "formType";

	/**
	 * 字段 formId
	 */
	public static final String FILED_FORM_ID = "formId";

	/**
	 * 字段 formNo
	 */
	public static final String FILED_FORM_NO = "formNo";

	/**
	 * 字段 flowName
	 */
	public static final String FILED_FLOW_NAME = "flowName";

	/**
	 * 字段 flowTitle
	 */
	public static final String FILED_FLOW_TITLE = "flowTitle";

	/**
	 * 字段 processId
	 */
	public static final String FILED_PROCESS_ID = "processId";

	/**
	 * 字段 processInstanceId
	 */
	public static final String FILED_PROCESS_INSTANCE_ID = "processInstanceId";

	/**
	 * 字段 processDefinitionId
	 */
	public static final String FILED_PROCESS_DEFINITION_ID = "processDefinitionId";

	/**
	 * 字段 processDefinitionVersion
	 */
	public static final String FILED_PROCESS_DEFINITION_VERSION = "processDefinitionVersion";

	/**
	 * 字段 startUserId
	 */
	public static final String FILED_START_USER_ID = "startUserId";

	/**
	 * 字段 startUserName
	 */
	public static final String FILED_START_USER_NAME = "startUserName";

	/**
	 * 字段 status
	 */
	public static final String FILED_STATUS = "status";

	/**
	 * 字段 statusMessage
	 */
	public static final String FILED_STATUS_MESSAGE = "statusMessage";

	/**
	 * 字段 processResult
	 */
	public static final String FILED_PROCESS_RESULT = "processResult";

	/**
	 * 字段 startDate
	 */
	public static final String FILED_START_DATE = "startDate";

	/**
	 * 字段 endDate
	 */
	public static final String FILED_END_DATE = "endDate";

	/**
	 * 表单类型
	 */
	@NotNull(message = "表单类型不能为空")
	@Column(name = "form_type", nullable = false)
	@ColumnOrder(1)
	@Index
	private Integer formType;

	/**
	 * 表单id
	 */
	@NotNull(message = "表单Id不能为空")
	@Column(name = "form_id", nullable = false)
	@ColumnOrder(2)
	@Index
	private Long formId;

	/**
	 * 表单编号
	 */
	@NotNullOrBlank(message = "表单编号不能为空")
	@Length(max = MAX_FORM_NO_LENGTH, message = "表单编号长度不能超过" + MAX_FORM_NO_LENGTH + "个字。")
	@Column(name = "form_no", nullable = false, length = MAX_FORM_NO_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(3)
	@Index
	private String formNo;

	/**
	 * 流程名称
	 */
	@NotNullOrBlank(message = "流程名称不能为空")
	@Length(max = MAX_FLOW_NAME_LENGTH, message = "流程名称长度不能超过" + MAX_FLOW_NAME_LENGTH + "个字。")
	@Column(name = "form_name", nullable = false, length = MAX_FLOW_NAME_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(4)
	@Index
	private String flowName;

	@NotNullOrBlank(message = "流程标题不能为空")
	@Length(max = MAX_FLOW_TITLE_LENGTH, message = "流程标题长度不能超过" + MAX_FLOW_TITLE_LENGTH + "个字。")
	@Column(name = "flow_title", nullable = false, length = MAX_FLOW_TITLE_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(5)
	@Index
	private String flowTitle;

	@NotNullOrBlank(message = "流程id不能为空")
	@Length(max = MAX_PROCESS_ID_LENGTH, message = "流程id长度不能超过" + MAX_PROCESS_ID_LENGTH + "个字。")
	@Column(name = "process_id", nullable = false, length = MAX_PROCESS_ID_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(6)
	@Index
	private String processId;

	@NotNullOrBlank(message = "流程实例id不能为空")
	@Length(max = MAX_PROCESS_INSTANCE_ID_LENGTH, message = "流程实例id长度不能超过" + MAX_PROCESS_INSTANCE_ID_LENGTH + "个字。")
	@Column(name = "process_instance_id", nullable = false, length = MAX_PROCESS_INSTANCE_ID_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(7)
	@Index
	private String processInstanceId;

	@NotNullOrBlank(message = "流程定义id不能为空")
	@Length(max = MAX_PROCESS_DEFINITION_ID_LENGTH, message = "流程定义id长度不能超过" + MAX_PROCESS_DEFINITION_ID_LENGTH + "个字。")
	@Column(name = "process_definition_id", nullable = false, length = MAX_PROCESS_DEFINITION_ID_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(8)
	@Index
	private String processDefinitionId;

	/**
	 * 启动用户
	 */
	@NotNull(message = "启动用户id不能为空")
	@Length(max = MAX_START_USER_ID_LENGTH, message = "启动用户id长度不能超过" + MAX_START_USER_ID_LENGTH + "个字。")
	@Column(name = "start_user_id", nullable = false, length = MAX_START_USER_ID_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@Index
	@ColumnOrder(10)
	private String startUserId;

	/**
	 * 表单标题
	 */
	@NotNullOrBlank(message = "启动用户名称不能为空")
	@Length(max = MAX_START_USER_NAME_LENGTH, message = "启动用户名称长度不能超过" + MAX_START_USER_NAME_LENGTH + "个字。")
	@Column(name = "start_user_name", nullable = false, length = MAX_START_USER_NAME_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(11)
	private String startUserName;

	/**
	 * 状态 {@link com.autumn.zero.workflow.constants.ProcessStatusConstants}
	 */
	@NotNull(message = "状态不能为空")
	@Column(name = "status", nullable = false)
	@ColumnOrder(12)
	private Integer status;

	/**
	 * 状态消息
	 */
	@Length(max = MAX_STATUS_MESSAGE_LENGTH, message = "状态消息长度不能超过" + MAX_STATUS_MESSAGE_LENGTH + "个字。")
	@Column(name = "status_message", nullable = false, length = MAX_STATUS_MESSAGE_LENGTH)
	@ColumnType(jdbcType = JdbcType.VARCHAR)
	@ColumnOrder(13)
	private String statusMessage;

	/**
	 * 流程结果 {@link com.autumn.zero.workflow.constants.ProcessResultConstants}
	 */
	@NotNull(message = "流程结果不能为空")
	@Column(name = "process_result", nullable = false)
	@ColumnOrder(14)
	private Integer processResult;

	/**
	 * 开始日期
	 */
	@ColumnOrder(15)
	private Date startDate;

	/**
	 * 结束日期
	 */
	@ColumnOrder(16)
	private Date endDate;

	public Integer getFormType() {
		return formType;
	}

	public void setFormType(Integer formType) {
		this.formType = formType;
	}

	public Long getFormId() {
		return formId;
	}

	public void setFormId(Long formId) {
		this.formId = formId;
	}

	public String getFormNo() {
		return formNo;
	}

	public void setFormNo(String formNo) {
		this.formNo = formNo;
	}

	public String getFlowName() {
		return flowName;
	}

	public void setFlowName(String flowName) {
		this.flowName = flowName;
	}

	public String getFlowTitle() {
		return flowTitle;
	}

	public void setFlowTitle(String flowTitle) {
		this.flowTitle = flowTitle;
	}

	public String getProcessId() {
		return processId;
	}

	public void setProcessId(String processId) {
		this.processId = processId;
	}

	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	public String getProcessDefinitionId() {
		return processDefinitionId;
	}

	public void setProcessDefinitionId(String processDefinitionId) {
		this.processDefinitionId = processDefinitionId;
	}

	public String getStartUserId() {
		return startUserId;
	}

	public void setStartUserId(String startUserId) {
		this.startUserId = startUserId;
	}

	public String getStartUserName() {
		return startUserName;
	}

	public void setStartUserName(String startUserName) {
		this.startUserName = startUserName;
	}

	/**
	 * 获取状态
	 * 
	 * @return {@link com.autumn.zero.workflow.constants.ProcessStatusConstants}
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * 设置状态
	 * 
	 * @param status {@link com.autumn.zero.workflow.constants.ProcessStatusConstants}
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getStatusMessage() {
		return statusMessage;
	}

	public void setStatusMessage(String statusMessage) {
		this.statusMessage = statusMessage;
	}

	/**
	 * 
	 * @return {@link com.autumn.zero.workflow.constants.ProcessResultConstants}
	 */
	public Integer getProcessResult() {
		return processResult;
	}

	/**
	 * 
	 * @param processResult {@link com.autumn.zero.workflow.constants.ProcessResultConstants}
	 */
	public void setProcessResult(Integer processResult) {
		this.processResult = processResult;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
